home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / utils / adt / bool.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  821 b   |  50 lines

  1. /*
  2.  * bool.c --
  3.  *     Functions for the built-in type "bool".
  4.  */
  5.  
  6. #include "tmp/c.h"
  7. #include "utils/log.h"
  8.  
  9. RcsId("$Header: /private/postgres/src/utils/adt/RCS/bool.c,v 1.8 1992/02/05 03:42:40 mer Exp $");
  10.  
  11. #include "utils/palloc.h"
  12.  
  13.         /* ========== USER I/O ROUTINES ========== */
  14.  
  15.  
  16. /*
  17.  *    boolin        - converts "t" or "f" to 1 or 0
  18.  */
  19. int32
  20. boolin(b)
  21.     char    *b;
  22. {
  23.     if (b == NULL)
  24.         elog(WARN, "Bad input string for type bool");
  25.     return((int32) (*b == 't') || (*b == 'T'));
  26. }
  27.  
  28. /*
  29.  *    boolout        - converts 1 or 0 to "t" or "f"
  30.  */
  31. char *
  32. boolout(b)
  33.     long    b;
  34. {
  35.     char    *result = (char *) palloc(2);
  36.  
  37.     *result = (b) ? 't' : 'f';
  38.     result[1] = '\0';
  39.     return(result);
  40. }
  41.  
  42.  
  43.          /* ========== PUBLIC ROUTINES ========== */
  44.  
  45.      /* (see int.c for comparison/operation routines) */
  46.  
  47.  
  48.          /* ========== PRIVATE ROUTINES ========== */
  49.  
  50.